HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: /var/www/kevin-demo/wp-content/plugins/grocerslist/includes/Support/Logger.php
<?php

namespace GrocersList\Support;

/**
 * Logger class for handling debug logging in a way that can be disabled in production.
 */
class Logger
{
    /**
     * Whether debug logging is enabled.
     *
     * @var bool
     */
    private static bool $enabled = false;

    /**
     * Enable debug logging.
     *
     * @return void
     */
    public static function enable(): void
    {
        self::$enabled = true;
    }

    /**
     * Disable debug logging.
     *
     * @return void
     */
    public static function disable(): void
    {
        self::$enabled = false;
    }

    /**
     * Check if debug logging is enabled.
     *
     * @return bool
     */
    public static function isEnabled(): bool
    {
        return self::$enabled;
    }

    /**
     * Log a debug message if logging is enabled.
     *
     * @param string $message The message to log.
     * @return void
     */
    public static function debug(string $message): void
    {
        if (self::$enabled) {
            // phpcs:disable WordPress.PHP.DevelopmentFunctions
            error_log($message);
            // phpcs:enable
        }
    }
}